import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
//导入vue-router
import {createRouter} from "./router"
//导入VueX
import store from './store'

//导入 Axios 请求接口的工具
import axios from 'axios'
import VueAxios from 'vue-axios'


import Vant from 'vant'
// 2. 引入组件样式
import 'vant/lib/index.css';

//设置后端接口的统一前缀
axios.defaults.baseURL = 'http://localhost:8081/api/'

// axios请求拦截 让每次请求都携带令牌
axios.interceptors.request.use(
    config => {
        config.headers['shopifyplus-token'] = store.state.token;
        return config;
    },
    error => {
        return Promise.reject(error);
    }
);

createApp(App).
use(createRouter()).
use(store).
use(Vant).
use(VueAxios, axios).
mount('#app')
